<include file="Public/head" />
<div class="tableContainer">
	<div class="tablePanel">
		<div class="edit-title" style="height:56px;">
			<!-- 有title-icon1至title-icon14共14个图标可供选择 -->
			<span class="title-icon11"></span>
			<div><h4 style="float:left;margin-left:10px;">接口配置信息<span style="font-size:12px;font-weight:normal;color:#999;">（复制接口配置信息。登陆公众帐号，进入开发 -&gt; 基本配置 -&gt; 填写相应的URL和Token进行验证。）</span></h4></div>
		</div>
		<div class="edit-body">
			<form role="form" method="post" id="autoreplyform">
				<div class="set-line">
					<div class="set-title">AppID：</div>
					<div class="set-ctrl">
						<input name="appid" style="width:500px;" value="<{$customerRow.appid}>" type="text" />
					</div>
				</div>
				<div class="set-line">
					<div class="set-title">AppSecret：</div>
					<div class="set-ctrl">
						<input name="appsecret" style="width:500px;" value="<{$customerRow.appsecret}>" type="text" />
					</div>
				</div>
				<div class="set-line">
					<div class="set-title">JsSDK认证文件</div>
					<div class="set-ctrl">
						<div class="uploadWrapper" style="width:500px;">点击上传
							<input class="uploadFile" style="width:500px;" type="file" id="pic" name="pic" onchange="upload_img('pic')" />
						</div>
						<span style="color:#666;">&nbsp;&nbsp;&nbsp;从微信后台配置js安全域名处下载</span>
					</div>
				</div>
				<if condition="$customerRow.appid neq '' and $customerRow.appsecret neq ''">
					<div class="set-line">
						<div class="set-title">接口URL：</div>
						<div class="set-ctrl">
							<input style="width:500px;" value="<{$url}>" type="text" onclick="this.select()" readonly />
						</div>
					</div>
					<div class="set-line">
						<div class="set-title">接口Token：</div>
						<div class="set-ctrl">
							<input style="width:500px;" value="<{$token}>" type="text" onclick="this.select()" readonly />
						</div>
					</div>
		        </if>
		        <div class="save">
					<span onclick="save(this)" id="saveBtn" class="saveBtn" style="float:left;">提交保存</span>
				</div>
		    </form>
		</div>
	</div>
</div>
<!-- 上传js认证文件开始 -->
<script type='text/javascript' src='__PUBLIC__/js/ajaxfileupload.js'></script>
<script type="text/javascript">
    //width height 要压缩成的图片宽 高，默认0代表不限制
    function upload_img(id, width, height){
        if(id == '' || id == null) return;
        if(!width) width = 0;
        if(!height) height = 0;

        var loadIndex = layer.load(1);
        $.ajaxFileUpload ({
             url: '<{:U("Admin/PicUpload/wx_grant")}>',
             data: {width: width, height: height},
             secureuri: false,
             fileElementId: id,
             dataType: 'json',
             success: function (data,status){
                layer.close(loadIndex);
                if(data.status){
					note_info(data.info,$('#'+id))
                }else{
                    note_info(data.info,$('#'+id),'warn')
                }
             }
        });
    }
</script>
<!-- 上传结束 -->
<script>
function save(obj){
	var appid = $.trim($('input[name=appid]').val());
	var appsecret = $.trim($('input[name=appsecret]').val());
	$.post(
		"<{:U('url_token')}>",
		{appid:appid,appsecret:appsecret},
		function(data){
			if(data.status=='1'){
				note_info(data.info,obj);
				setTimeout("location.reload()",1200);
			}else{
				note_info(data.info,obj,'warn');
			}
		},'json'
	);
}
</script>
<include file="Public/foot" />